﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Resources;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace telefonia
{
    public partial class Cliente : Form
    {
        private ResourceManager resours;
        public Cliente()
        {
            InitializeComponent();
            resours = new ResourceManager(typeof(Cliente));
        }

        private void bCancelar_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void bGuardar_Click(object sender, EventArgs e)
        {
            ClientModel cli = new ClientModel();
            cli.Nombres = xTnombres.Text.Trim();
            cli.Apellidos = xTapellidos.Text.Trim();
            cli.CI = xTci.Text.Trim();
            cli.Email = xTcorreo.Text.Trim();
            cli.LugarEmisionCI = cbEmiCi.Items[cbEmiCi.SelectedIndex].ToString();
            cli.TelefonoContacto = xTcontacto.Text.Trim();
            cli.PersonaContacto = xTcontacto.Text.Trim();
            cli.DepartamentoResidencia = cBResidencia.SelectedIndex != -1 ? cBResidencia.Items[cBResidencia.SelectedIndex].ToString() : null;
            cli.DireccionDomicilio = xTDirDomicilio.Text.Trim();
            cli.DireccionLaboral = xTDirLaboral.Text.Trim();
            if (DataBase.AddClient(cli))
            {
                string caption = this.resours.GetString("messageBox.Caption");
                MessageBoxButtons buttons = MessageBoxButtons.OK;
                MessageBox.Show(this, "Cliente creado satisfactoriamente", caption, buttons, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign);

            }

            this.Close();
        }
    }

}
